package com.mew.common.exception;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * type :   0 普通提示， 1，弹到大厅， 2， 弹到登录， 3，重新读取服务器连接
 */
public enum ResponseCode {

    /**  系统  */
    Success(200, 0, "SUCCESS"),            // "成功"),
    SysException(500, 0, "系统开小差了"),      // 系统异常， "系统开小差了"), 业务方面的错误! 这种错误需要不断调试尽量将到最低

    GatewayDowntime(555, 3, "不可抗555"),   // 网关挂掉 1，重新获取网关地址, 2，重新进入大厅；
    GameServerDowntime(560, 1, "不可抗560"), // 子游戏TMS 需要客户端 返回大厅；
    LobbyServerDowntime(570, 3, "不可抗570"), // 大厅服务器挂了; 整个服务不能使用了; 只有网关可以用 ； 返回登录界面

    InactiveChannel(616, 0, "InactiveChannel"),      //该消息号用于网关断线; 不一定登录失效
    LoginUn(666, 2, "您的登录信息已失效,请重新登录"),  // 您的登录信息已失效, 请重新登录!    账号出现异常,请重新登录！ 客户退回登录界面
    EnterRoomUn(777, 1, "进入子游戏异常，返回大厅"),
    InMaintenance(778, 2, "系统维护中"),
    OnlineMax(999, 0, "玩家达到上限,稍后重试"),
    //公共业务 消息
    ParamInvalid(1000, 0, "参数无效"), //, 0, "请求参数无效，请重新输入" 模糊提示, 不用精确提示，以免安全漏洞


    LoginFailed(1001, 2, "登录信息错误"),//游客登录：gameId跟mac不匹配

    /** 活动 错误码 **/
    DaysNotGet(1010, 0, "未到时间!"),
    DaysNotWheel(1011, 0, "未达到转动次数!"),
    DaysGet(1012, 0, "已领取!"),

    /**  1100  联盟 **/
    InLeague(1101,1,"您已拥有联盟"),
    CreateLeague(1102,1,"创建失败，请重试"),
    NoLeague(1103,1,"未找到该联盟"),
    FullLeague(1104,1,"抱歉，公会人数已满！"),


    /** 购买金币 错误码 **/
    GoldDealConfigIsNull(1401,0,"加载购买条目失败，请重试！"),
    BelowVip(1402,0,"抱歉!未开启交易功能！"),
    JewelNumberNo(1403, 0, "钻石不足"),
    NoProduct(1404, 0, "没有该商品"),
    HaveProduct(1405, 0, "订单已被使用"),

    /*转账*/
    CanNotTran(1500,0,"未开启转账"),
    NeedSMS(1501,0,"需要短信验证"),
    GoldNotMet(1502,0,"未满足最低金额"),

    /** 大厅 用户 **/
    UserTelInvalid(6100, 0, "电话号码无效"),


    UserTelRepeat(6101, 0,  "电话号码重复"),
    UserNotInfo(6102, 0, "账号或者密码错误"),
    UserErrorInfo(6103, 0, "账号有误请联系管理员"),
    UserState(6104, 0, "用户无效"),
    UserNotExist(6105, 0, "用户不存在"),
    SMSFail(6106, 0, "发送短信失败"),
    AuthCode(6107, 0, "验证码错误"),
    SignNot(6108, 0, "签到失败请重新进入签到界面"),
    SignDID(6109, 0, "您已签到"),
    SignPlayTimes(6110, 0, "未达到游戏次数"),
    SignSignTimes(6111, 0, "未达到签到次数"),
    SignGain(6112, 0, "您已领取"),
    UserRepeat(6113, 0, "账号重复"),
    notChangeName(6114,0, "无修改次数，修改失败"),
    notSignRepeat(6115,0, "无补签次数，补签失败"),
    bindInviteMax(6116,0, "该账号已达推荐人数上限"),
    MailReceived(6117,0, "邮件已领取"),
    FriendMax(6118,0,"抱歉，您的好友人数已满！"),
    FriendNotFound(6119,0,"抱歉，没有找到对应玩家！"),
    FriendIsOneself(6120,0,"抱歉，您不能添加自己为好友！"),
    FriendPresented(6121,0,"抱歉,您已经赠送过了！"),
    NoTel(6122, 0, "未绑定手机号"),
    NoTUserTel(6123, 0, "抱歉，手机号与当前账号绑定的手机号不一致。"),
    IsFriendCannotAdd(6124, 0, "该用户已是好友，无需重复添加！"),
    notFriend(6125, 0, "该用户和您不是好友关系！"),
    notBindOneself(6127,0,  "不能绑定自己"),
    hasInviter(6128,0, "已绑定邀请码"),
    UserTelError(6129, 0, "电话号码错误"),
    LengthToMAx(6130,0,"内容长度超出限制！"),
    IsFriend(6131,0,"对方已是好友，操作失败！"),

    AgentBindRepeat(6132,0,"该账号已有绑定代理，禁止变更！"),
    AgentNotFind(6133,0,"代理码无效"),
    AgentExtractUnLevel(6134,0,"代理等级未达到提取标准！"),
    AgentExtractFail(6135,0,"提取失敗，请刷新重试！"),

    AccountIsUse(6136,0,"账号重复！"),

    /** 大厅 游戏配置 6200 **/
    GameServerNotConfig(6200, 0, "该游戏暂未开发"),
    GameRoomNotConfig(6202, 0, "该房间暂未开发"),
    LevelNotVip(6210, 0, "未知VIP"),
    LevelNotUser(6211, 0, "未知LV"),
    GradeDoNotPlay(6212, 0, "请升级解锁游戏"),


    /**
     * 游戏 7000
     */
    VIPCanNotPlay(7700, 0, "VIP不能玩游戏"),
    BetError(7720, 1, "押注错误"),
    GoldNo(7721, 0, "金额不足"),
    WinFreeValidError(7722, 1, "免费验证错误"),
    BounsCanNotPlay(7740, 1, "无特殊游戏"),
    BounsParamInvalid(7741, 1, "特殊游戏参数错误"),

    //棋牌
    RoomFull(8000, 1, "该房间人数已满"),
    StopBet(8001, 0, "已停止押注"),
    ChessPaying(8002, 0, "棋牌中不能退出"),
    BetMax(8003, 0, "押注达到上限"),
    RoomNotFound(8004, 0, "房间不存在"),
    UserNotFound(8005, 0, "玩家信息不存在")
    ;



    private final int code;
    private final int codeType;
    private final String msg;

    ResponseCode(int code, int codeType, String msg) {
        this.code = code;
        this.codeType = codeType;
        this.msg = msg;
    }
    private final static Map<Integer, ResponseCode> codeMap = Arrays.stream(ResponseCode.values()).collect(Collectors.toMap(ResponseCode::code, code -> code));
    public int code() {
        return this.code;
    }

    public int codeType() {
        return this.codeType;
    }

    public String msg(){
        return this.msg;
    }

    public static Map<Integer, ResponseCode> getCodeMap() {
        return codeMap;
    }

}
